package com.qk.management.service.impl;

import cn.hutool.ai.model.openai.OpenaiService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.common.PageResult;
import com.qk.domain.log.LogPageDO;
import com.qk.dto.log.LogPageDTO;
import com.qk.entity.OperateLog;
import com.qk.management.mapper.OperateLogMapper;
import com.qk.management.service.OperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService {
    @Autowired
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult<LogPageDO> pageLogs(LogPageDTO dto) {
        Page pages = new Page<>(dto.getPage(),dto.getPageSize());
        Page<LogPageDO> page = operateLogMapper.selectByPage(pages, dto);
        return PageResult.<LogPageDO>builder()
                .total(page.getTotal())
                .rows(page.getRecords())
                .build();
    }
}